﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace ComLib.ComFun
{
    public class CustomEncrypt
    {
        /// <summary>
        /// 将明文加密成密文
        /// </summary>
        /// <param name="plaintext">明文</param>
        /// <returns>密文</returns>
        public static string Encrypt(string plaintext)
        {
            byte[] buffer = System.Text.Encoding.Default.GetBytes(plaintext);//Convert.FromBase64String(str0);
            return Convert.ToBase64String(buffer);
        }

        /// <summary>
        /// 将密文还原成明文
        /// </summary>
        /// <param name="ciphertext"></param>
        /// <returns></returns>
        public static string Deciphering(string ciphertext)
        {
            byte[] buffer2 = Convert.FromBase64String(ciphertext);
            string plaintext = System.Text.Encoding.Default.GetString(buffer2);           
            return plaintext;
        }
    }
}
